﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ASmile.ORM.CodeBuilder
{
    public static class TypeNameHelper
    {
        private static readonly Dictionary<string, string> TypeMap = new Dictionary<string, string>
        {
            { "System.Byte", "byte" },
            { "System.SByte", "sbyte" },
            { "System.Int16", "short" },
            { "System.UInt16", "ushort" },
            { "System.Int32", "int" },
            { "System.UInt32", "uint" },
            { "System.Int64", "long" },
            { "System.UInt64", "ulong" },
            { "System.Single", "float" },
            { "System.Double", "double" },
            { "System.Decimal", "decimal" },
            { "System.Boolean", "bool" },
            { "System.Char", "char" },
            { "System.String", "string" },
            { "System.Object", "object" },
            { "System.Void", "void" }
        };

        public static string GetCSharpKeyword(string fullTypeName)
        {
            if (string.IsNullOrEmpty(fullTypeName))
                return fullTypeName;

            if (TypeMap.TryGetValue(fullTypeName, out string keyword))
                return keyword;

            return fullTypeName; // 未找到匹配时返回原始名称
        }
    }

}
